﻿using System;
using System.Windows.Controls;

namespace HomagChina.Nesting.Router
{
    public class Utility
    {
        public static object GetViewModelInstance(string typeName)
        {
            typeName = "HomagChina.Nesting." + typeName;
            var viewModelType = Type.GetType(typeName);
            if (viewModelType != null)
            {
                var viewModelInstance = Activator.CreateInstance(viewModelType);
                return viewModelInstance;
            }
            else
            {
                return null;
            }
        }

        public static UserControl GetUserControlInstance(string typeName)
        {
            typeName = "HomagChina.Nesting.Views." + typeName;
            var userControlType = Type.GetType(typeName);
            if (userControlType != null)
            {
                var userControlInstance = (UserControl)Activator.CreateInstance(userControlType);
                return userControlInstance;
            }
            else
            {
                return null;
            }
        }
    }
}